#!/usr/bin/env python
#coding:utf-8

import pygtk
import gtk
import gtk.glade

class message():

    def __init__(self):
        self.text = None
        self.text_in = None

    def gettext(self, widget):
        buf = widget.get_buffer()
        b, e = buf.get_bounds()
        return buf.get_text(b, e)


    def settext(self, widget, text = ''):
        buf = widget.get_buffer()
        buf.set_text(text)
        widget.set_buffer(buf)


class mywindow():

    def __init__(self):
        self.ui_file = 'test.glade'
        self.wTree = gtk.glade.XML(self.ui_file)
        self.window = self.wTree.get_widget('window1')
        self.window.show()
        
        dic = {'on_window1_clicked':gtk.main_quit,
               'on_button1_clicked':self.messageOut}
        self.wTree.signal_autoconnect(dic)
        self.window.connect('destroy',gtk.main_quit)

    def messageOut(self, widget):
        print widget.get_name()
        mess = self.wTree.get_widget('text_in').get_text()
        print mess

    def main(self):
        gtk.main()

if __name__ == '__main__':
    test = mywindow()
    test.main()

    
